package com.example.backend.controller;

import com.example.backend.entity.Score;
import com.example.backend.service.ScoreService;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@CrossOrigin
@Log4j
public class ScoerController {

    @Autowired
    private ScoreService scoreService;


    @PostMapping("/score")
    public int addScore(@RequestBody Score score){
        return scoreService.addScore(score);
    }
    @GetMapping("/score/{dingdan_num}")
    public ArrayList<Score> selectScoreByNum(@PathVariable String dingdan_num){
        return scoreService.selectScoreByNum(dingdan_num);
    }

    @GetMapping("/score")
    public ArrayList<Score> selectAll(){
        return scoreService.selectAll();
    }

    @PutMapping("/score")
    public int updateScore(@RequestBody Score score){
        return scoreService.updateScore(score);
    }



    @DeleteMapping("/score/{dingdan_num}")
    public int deleteScoreByNum(@PathVariable String dingdan_num){
        return scoreService.deleteScoreByNum(dingdan_num);
    }
}
